{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Wine"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Introduction:\n",
    "\n",
    "This exercise is a adaptation from the UCI Wine dataset.\n",
    "The only pupose is to practice deleting data with pandas.\n",
    "\n",
    "### Step 1. Import the necessary libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 2. Import the dataset from this [address](https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data). "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 3. Assign it to a variable called wine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>1</th>\n",
       "      <th>14.23</th>\n",
       "      <th>1.71</th>\n",
       "      <th>2.43</th>\n",
       "      <th>15.6</th>\n",
       "      <th>127</th>\n",
       "      <th>2.8</th>\n",
       "      <th>3.06</th>\n",
       "      <th>.28</th>\n",
       "      <th>2.29</th>\n",
       "      <th>5.64</th>\n",
       "      <th>1.04</th>\n",
       "      <th>3.92</th>\n",
       "      <th>1065</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>13.20</td>\n",
       "      <td>1.78</td>\n",
       "      <td>2.14</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100</td>\n",
       "      <td>2.65</td>\n",
       "      <td>2.76</td>\n",
       "      <td>0.26</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "      <td>1.05</td>\n",
       "      <td>3.40</td>\n",
       "      <td>1050</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>13.16</td>\n",
       "      <td>2.36</td>\n",
       "      <td>2.67</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101</td>\n",
       "      <td>2.80</td>\n",
       "      <td>3.24</td>\n",
       "      <td>0.30</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "      <td>1.03</td>\n",
       "      <td>3.17</td>\n",
       "      <td>1185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>14.37</td>\n",
       "      <td>1.95</td>\n",
       "      <td>2.50</td>\n",
       "      <td>16.8</td>\n",
       "      <td>113</td>\n",
       "      <td>3.85</td>\n",
       "      <td>3.49</td>\n",
       "      <td>0.24</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "      <td>0.86</td>\n",
       "      <td>3.45</td>\n",
       "      <td>1480</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>2.87</td>\n",
       "      <td>21.0</td>\n",
       "      <td>118</td>\n",
       "      <td>2.80</td>\n",
       "      <td>2.69</td>\n",
       "      <td>0.39</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "      <td>1.04</td>\n",
       "      <td>2.93</td>\n",
       "      <td>735</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>14.20</td>\n",
       "      <td>1.76</td>\n",
       "      <td>2.45</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112</td>\n",
       "      <td>3.27</td>\n",
       "      <td>3.39</td>\n",
       "      <td>0.34</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "      <td>1.05</td>\n",
       "      <td>2.85</td>\n",
       "      <td>1450</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   1  14.23  1.71  2.43  15.6  127   2.8  3.06   .28  2.29  5.64  1.04  3.92  \\\n",
       "0  1  13.20  1.78  2.14  11.2  100  2.65  2.76  0.26  1.28  4.38  1.05  3.40   \n",
       "1  1  13.16  2.36  2.67  18.6  101  2.80  3.24  0.30  2.81  5.68  1.03  3.17   \n",
       "2  1  14.37  1.95  2.50  16.8  113  3.85  3.49  0.24  2.18  7.80  0.86  3.45   \n",
       "3  1  13.24  2.59  2.87  21.0  118  2.80  2.69  0.39  1.82  4.32  1.04  2.93   \n",
       "4  1  14.20  1.76  2.45  15.2  112  3.27  3.39  0.34  1.97  6.75  1.05  2.85   \n",
       "\n",
       "   1065  \n",
       "0  1050  \n",
       "1  1185  \n",
       "2  1480  \n",
       "3   735  \n",
       "4  1450  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data'\n",
    "wine = pd.read_csv(url)\n",
    "\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 4. Delete the first, fourth, seventh, nineth, eleventh, thirteenth and fourteenth columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>14.23</th>\n",
       "      <th>1.71</th>\n",
       "      <th>15.6</th>\n",
       "      <th>127</th>\n",
       "      <th>3.06</th>\n",
       "      <th>2.29</th>\n",
       "      <th>5.64</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>13.20</td>\n",
       "      <td>1.78</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13.16</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>14.37</td>\n",
       "      <td>1.95</td>\n",
       "      <td>16.8</td>\n",
       "      <td>113</td>\n",
       "      <td>3.49</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>21.0</td>\n",
       "      <td>118</td>\n",
       "      <td>2.69</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>14.20</td>\n",
       "      <td>1.76</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112</td>\n",
       "      <td>3.39</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   14.23  1.71  15.6  127  3.06  2.29  5.64\n",
       "0  13.20  1.78  11.2  100  2.76  1.28  4.38\n",
       "1  13.16  2.36  18.6  101  3.24  2.81  5.68\n",
       "2  14.37  1.95  16.8  113  3.49  2.18  7.80\n",
       "3  13.24  2.59  21.0  118  2.69  1.82  4.32\n",
       "4  14.20  1.76  15.2  112  3.39  1.97  6.75"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine = wine.drop(wine.columns[[0,3,6,8,11,12,13]], axis = 1)\n",
    "\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 5. Assign the columns as below:\n",
    "\n",
    "The attributes are (donated by Riccardo Leardi, riclea '@' anchem.unige.it):  \n",
    "1) alcohol  \n",
    "2) malic_acid  \n",
    "3) alcalinity_of_ash  \n",
    "4) magnesium  \n",
    "5) flavanoids  \n",
    "6) proanthocyanins  \n",
    "7) hue "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>13.20</td>\n",
       "      <td>1.78</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13.16</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>14.37</td>\n",
       "      <td>1.95</td>\n",
       "      <td>16.8</td>\n",
       "      <td>113</td>\n",
       "      <td>3.49</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>21.0</td>\n",
       "      <td>118</td>\n",
       "      <td>2.69</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>14.20</td>\n",
       "      <td>1.76</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112</td>\n",
       "      <td>3.39</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "0    13.20        1.78               11.2        100        2.76   \n",
       "1    13.16        2.36               18.6        101        3.24   \n",
       "2    14.37        1.95               16.8        113        3.49   \n",
       "3    13.24        2.59               21.0        118        2.69   \n",
       "4    14.20        1.76               15.2        112        3.39   \n",
       "\n",
       "   proanthocyanins   hue  \n",
       "0             1.28  4.38  \n",
       "1             2.81  5.68  \n",
       "2             2.18  7.80  \n",
       "3             1.82  4.32  \n",
       "4             1.97  6.75  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.columns = ['alcohol', 'malic_acid', 'alcalinity_of_ash', 'magnesium', 'flavanoids', 'proanthocyanins', 'hue']\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 6. Set the values of the first 3 rows from alcohol as NaN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.78</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.95</td>\n",
       "      <td>16.8</td>\n",
       "      <td>113</td>\n",
       "      <td>3.49</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>21.0</td>\n",
       "      <td>118</td>\n",
       "      <td>2.69</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>14.20</td>\n",
       "      <td>1.76</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112</td>\n",
       "      <td>3.39</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "0      NaN        1.78               11.2        100        2.76   \n",
       "1      NaN        2.36               18.6        101        3.24   \n",
       "2      NaN        1.95               16.8        113        3.49   \n",
       "3    13.24        2.59               21.0        118        2.69   \n",
       "4    14.20        1.76               15.2        112        3.39   \n",
       "\n",
       "   proanthocyanins   hue  \n",
       "0             1.28  4.38  \n",
       "1             2.81  5.68  \n",
       "2             2.18  7.80  \n",
       "3             1.82  4.32  \n",
       "4             1.97  6.75  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.iloc[0:3, 0] = np.nan\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 7. Now set the value of the rows 3 and 4 of magnesium as NaN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.78</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.95</td>\n",
       "      <td>16.8</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.49</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>21.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.69</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>14.20</td>\n",
       "      <td>1.76</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112.0</td>\n",
       "      <td>3.39</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "0      NaN        1.78               11.2      100.0        2.76   \n",
       "1      NaN        2.36               18.6      101.0        3.24   \n",
       "2      NaN        1.95               16.8        NaN        3.49   \n",
       "3    13.24        2.59               21.0        NaN        2.69   \n",
       "4    14.20        1.76               15.2      112.0        3.39   \n",
       "\n",
       "   proanthocyanins   hue  \n",
       "0             1.28  4.38  \n",
       "1             2.81  5.68  \n",
       "2             2.18  7.80  \n",
       "3             1.82  4.32  \n",
       "4             1.97  6.75  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.iloc[2:4, 3] = np.nan\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 8. Fill the value of NaN with the number 10 in alcohol and 100 in magnesium"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10.00</td>\n",
       "      <td>1.78</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10.00</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10.00</td>\n",
       "      <td>1.95</td>\n",
       "      <td>16.8</td>\n",
       "      <td>100.0</td>\n",
       "      <td>3.49</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>21.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.69</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>14.20</td>\n",
       "      <td>1.76</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112.0</td>\n",
       "      <td>3.39</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "0    10.00        1.78               11.2      100.0        2.76   \n",
       "1    10.00        2.36               18.6      101.0        3.24   \n",
       "2    10.00        1.95               16.8      100.0        3.49   \n",
       "3    13.24        2.59               21.0      100.0        2.69   \n",
       "4    14.20        1.76               15.2      112.0        3.39   \n",
       "\n",
       "   proanthocyanins   hue  \n",
       "0             1.28  4.38  \n",
       "1             2.81  5.68  \n",
       "2             2.18  7.80  \n",
       "3             1.82  4.32  \n",
       "4             1.97  6.75  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.alcohol.fillna(10, inplace = True)\n",
    "\n",
    "wine.magnesium.fillna(100, inplace = True)\n",
    "\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 9. Count the number of missing values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "alcohol              0\n",
       "malic_acid           0\n",
       "alcalinity_of_ash    0\n",
       "magnesium            0\n",
       "flavanoids           0\n",
       "proanthocyanins      0\n",
       "hue                  0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.isnull().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 10.  Create an array of 10 random numbers up until 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 3, 0, 5, 0, 9, 4, 0, 7, 2])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random = np.random.randint(10, size = 10)\n",
    "random"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 11.  Use random numbers you generated as an index and assign NaN value to each of cell."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.78</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10.00</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.95</td>\n",
       "      <td>16.8</td>\n",
       "      <td>100.0</td>\n",
       "      <td>3.49</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2.59</td>\n",
       "      <td>21.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.69</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.76</td>\n",
       "      <td>15.2</td>\n",
       "      <td>112.0</td>\n",
       "      <td>3.39</td>\n",
       "      <td>1.97</td>\n",
       "      <td>6.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.87</td>\n",
       "      <td>14.6</td>\n",
       "      <td>96.0</td>\n",
       "      <td>2.52</td>\n",
       "      <td>1.98</td>\n",
       "      <td>5.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>14.06</td>\n",
       "      <td>2.15</td>\n",
       "      <td>17.6</td>\n",
       "      <td>121.0</td>\n",
       "      <td>2.51</td>\n",
       "      <td>1.25</td>\n",
       "      <td>5.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.64</td>\n",
       "      <td>14.0</td>\n",
       "      <td>97.0</td>\n",
       "      <td>2.98</td>\n",
       "      <td>1.98</td>\n",
       "      <td>5.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>13.86</td>\n",
       "      <td>1.35</td>\n",
       "      <td>16.0</td>\n",
       "      <td>98.0</td>\n",
       "      <td>3.15</td>\n",
       "      <td>1.85</td>\n",
       "      <td>7.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2.16</td>\n",
       "      <td>18.0</td>\n",
       "      <td>105.0</td>\n",
       "      <td>3.32</td>\n",
       "      <td>2.38</td>\n",
       "      <td>5.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "0      NaN        1.78               11.2      100.0        2.76   \n",
       "1    10.00        2.36               18.6      101.0        3.24   \n",
       "2      NaN        1.95               16.8      100.0        3.49   \n",
       "3      NaN        2.59               21.0      100.0        2.69   \n",
       "4      NaN        1.76               15.2      112.0        3.39   \n",
       "5      NaN        1.87               14.6       96.0        2.52   \n",
       "6    14.06        2.15               17.6      121.0        2.51   \n",
       "7      NaN        1.64               14.0       97.0        2.98   \n",
       "8    13.86        1.35               16.0       98.0        3.15   \n",
       "9      NaN        2.16               18.0      105.0        3.32   \n",
       "\n",
       "   proanthocyanins   hue  \n",
       "0             1.28  4.38  \n",
       "1             2.81  5.68  \n",
       "2             2.18  7.80  \n",
       "3             1.82  4.32  \n",
       "4             1.97  6.75  \n",
       "5             1.98  5.25  \n",
       "6             1.25  5.05  \n",
       "7             1.98  5.20  \n",
       "8             1.85  7.22  \n",
       "9             2.38  5.75  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.alcohol[random] = np.nan\n",
    "wine.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 12.  How many missing values do we have?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "alcohol              7\n",
       "malic_acid           0\n",
       "alcalinity_of_ash    0\n",
       "magnesium            0\n",
       "flavanoids           0\n",
       "proanthocyanins      0\n",
       "hue                  0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.isnull().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 13. Delete the rows that contain missing values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10.00</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>14.06</td>\n",
       "      <td>2.15</td>\n",
       "      <td>17.6</td>\n",
       "      <td>121.0</td>\n",
       "      <td>2.51</td>\n",
       "      <td>1.25</td>\n",
       "      <td>5.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>13.86</td>\n",
       "      <td>1.35</td>\n",
       "      <td>16.0</td>\n",
       "      <td>98.0</td>\n",
       "      <td>3.15</td>\n",
       "      <td>1.85</td>\n",
       "      <td>7.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>14.12</td>\n",
       "      <td>1.48</td>\n",
       "      <td>16.8</td>\n",
       "      <td>95.0</td>\n",
       "      <td>2.43</td>\n",
       "      <td>1.57</td>\n",
       "      <td>5.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>13.75</td>\n",
       "      <td>1.73</td>\n",
       "      <td>16.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.81</td>\n",
       "      <td>5.60</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "1     10.00        2.36               18.6      101.0        3.24   \n",
       "6     14.06        2.15               17.6      121.0        2.51   \n",
       "8     13.86        1.35               16.0       98.0        3.15   \n",
       "10    14.12        1.48               16.8       95.0        2.43   \n",
       "11    13.75        1.73               16.0       89.0        2.76   \n",
       "\n",
       "    proanthocyanins   hue  \n",
       "1              2.81  5.68  \n",
       "6              1.25  5.05  \n",
       "8              1.85  7.22  \n",
       "10             1.57  5.00  \n",
       "11             1.81  5.60  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine = wine.dropna(axis = 0, how = \"any\")\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 14. Print only the non-null values in alcohol"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1      True\n",
       "6      True\n",
       "8      True\n",
       "10     True\n",
       "11     True\n",
       "12     True\n",
       "13     True\n",
       "14     True\n",
       "15     True\n",
       "16     True\n",
       "17     True\n",
       "18     True\n",
       "19     True\n",
       "20     True\n",
       "21     True\n",
       "22     True\n",
       "23     True\n",
       "24     True\n",
       "25     True\n",
       "26     True\n",
       "27     True\n",
       "28     True\n",
       "29     True\n",
       "30     True\n",
       "31     True\n",
       "32     True\n",
       "33     True\n",
       "34     True\n",
       "35     True\n",
       "36     True\n",
       "       ... \n",
       "147    True\n",
       "148    True\n",
       "149    True\n",
       "150    True\n",
       "151    True\n",
       "152    True\n",
       "153    True\n",
       "154    True\n",
       "155    True\n",
       "156    True\n",
       "157    True\n",
       "158    True\n",
       "159    True\n",
       "160    True\n",
       "161    True\n",
       "162    True\n",
       "163    True\n",
       "164    True\n",
       "165    True\n",
       "166    True\n",
       "167    True\n",
       "168    True\n",
       "169    True\n",
       "170    True\n",
       "171    True\n",
       "172    True\n",
       "173    True\n",
       "174    True\n",
       "175    True\n",
       "176    True\n",
       "Name: alcohol, dtype: bool"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mask = wine.alcohol.notnull()\n",
    "mask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1      10.00\n",
       "6      14.06\n",
       "8      13.86\n",
       "10     14.12\n",
       "11     13.75\n",
       "12     14.75\n",
       "13     14.38\n",
       "14     13.63\n",
       "15     14.30\n",
       "16     13.83\n",
       "17     14.19\n",
       "18     13.64\n",
       "19     14.06\n",
       "20     12.93\n",
       "21     13.71\n",
       "22     12.85\n",
       "23     13.50\n",
       "24     13.05\n",
       "25     13.39\n",
       "26     13.30\n",
       "27     13.87\n",
       "28     14.02\n",
       "29     13.73\n",
       "30     13.58\n",
       "31     13.68\n",
       "32     13.76\n",
       "33     13.51\n",
       "34     13.48\n",
       "35     13.28\n",
       "36     13.05\n",
       "       ...  \n",
       "147    13.32\n",
       "148    13.08\n",
       "149    13.50\n",
       "150    12.79\n",
       "151    13.11\n",
       "152    13.23\n",
       "153    12.58\n",
       "154    13.17\n",
       "155    13.84\n",
       "156    12.45\n",
       "157    14.34\n",
       "158    13.48\n",
       "159    12.36\n",
       "160    13.69\n",
       "161    12.85\n",
       "162    12.96\n",
       "163    13.78\n",
       "164    13.73\n",
       "165    13.45\n",
       "166    12.82\n",
       "167    13.58\n",
       "168    13.40\n",
       "169    12.20\n",
       "170    12.77\n",
       "171    14.16\n",
       "172    13.71\n",
       "173    13.40\n",
       "174    13.27\n",
       "175    13.17\n",
       "176    14.13\n",
       "Name: alcohol, dtype: float64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.alcohol[mask]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 15.  Reset the index, so it starts with 0 again"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alcohol</th>\n",
       "      <th>malic_acid</th>\n",
       "      <th>alcalinity_of_ash</th>\n",
       "      <th>magnesium</th>\n",
       "      <th>flavanoids</th>\n",
       "      <th>proanthocyanins</th>\n",
       "      <th>hue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10.00</td>\n",
       "      <td>2.36</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>3.24</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14.06</td>\n",
       "      <td>2.15</td>\n",
       "      <td>17.6</td>\n",
       "      <td>121.0</td>\n",
       "      <td>2.51</td>\n",
       "      <td>1.25</td>\n",
       "      <td>5.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>13.86</td>\n",
       "      <td>1.35</td>\n",
       "      <td>16.0</td>\n",
       "      <td>98.0</td>\n",
       "      <td>3.15</td>\n",
       "      <td>1.85</td>\n",
       "      <td>7.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>14.12</td>\n",
       "      <td>1.48</td>\n",
       "      <td>16.8</td>\n",
       "      <td>95.0</td>\n",
       "      <td>2.43</td>\n",
       "      <td>1.57</td>\n",
       "      <td>5.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>13.75</td>\n",
       "      <td>1.73</td>\n",
       "      <td>16.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>2.76</td>\n",
       "      <td>1.81</td>\n",
       "      <td>5.60</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   alcohol  malic_acid  alcalinity_of_ash  magnesium  flavanoids  \\\n",
       "0    10.00        2.36               18.6      101.0        3.24   \n",
       "1    14.06        2.15               17.6      121.0        2.51   \n",
       "2    13.86        1.35               16.0       98.0        3.15   \n",
       "3    14.12        1.48               16.8       95.0        2.43   \n",
       "4    13.75        1.73               16.0       89.0        2.76   \n",
       "\n",
       "   proanthocyanins   hue  \n",
       "0             2.81  5.68  \n",
       "1             1.25  5.05  \n",
       "2             1.85  7.22  \n",
       "3             1.57  5.00  \n",
       "4             1.81  5.60  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine = wine.reset_index(drop = True)\n",
    "wine.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### BONUS: Create your own question and answer it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
